home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.07 Jul 90 / Data Exchange ƒ / driver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-19  |  1.0 KB  |  48 lines  |  [TEXT/MPS ]

  1. /*
  2.  * File Driver.c
  3.  */
  4.  
  5. #include    <types.h>
  6. #include <StdIO.h>
  7.  
  8. /*
  9.    Declare the stuff in Test.p
  10. */
  11. pascal void initialize (short) extern;
  12. pascal short getval () extern;
  13. /*
  14.    The following structure acts as a reference to the data in the pascal module
  15. <test.p> but it cannot be referenced directly because C assumes that the
  16. address of a structure points at its beginning and pascal points to the end
  17. of its data block.
  18. */
  19. extern struct testData {
  20.                 short a; 
  21.                      short b; 
  22.                      short c;
  23.                     } TEST;
  24.                     
  25. struct testData *tData;
  26.  
  27. int main()
  28. {
  29. /*
  30.    Adjust tData to point to the beginning of the Test global data block.
  31. */
  32.     tData = (&TEST) - 1; /* -1 subtracts sizeof(TEST) */
  33.  
  34.    tData->a = 2;
  35.    tData->b = 20;  
  36.    tData->c = 200;  
  37.  
  38.     printf ("Values set directly: %d, %d, %d.\n", tData->a, tData->b, tData->c);
  39.    initialize (98);
  40.     printf ("Value set indirectly to 98 is %d.\n", getval());
  41.     return 0;    
  42. }
  43. est.def
  44.    modula test.def
  45. test.a.o ƒ test.a
  46.    asm test.a
  47. driver.mod.o ƒ driver.mod test.SBM
  48.